1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| DELIMITER $$ DROP PROCEDURE IF EXISTS `aaaa`.`sp_status` $$ CREATE PROCEDURE `aaaa`.`sp_status`(dbname VARCHAR(50)) BEGIN -- Obtaining tables and views ( SELECT TABLE_NAME AS `Table Name`, ENGINE AS `Engine`, TABLE_ROWS AS `Rows`, CONCAT( (FORMAT((DATA_LENGTH + INDEX_LENGTH) / POWER(1024,2),2)) , ' Mb') AS `Size`, TABLE_COLLATION AS `Collation` FROM information_schema.TABLES WHERE TABLES.TABLE_SCHEMA = dbname AND TABLES.TABLE_TYPE = 'BASE TABLE' ) UNION ( SELECT TABLE_NAME AS `Table Name`, '[VIEW]' AS `Engine`, '-' AS `Rows`, '-' `Size`, '-' AS `Collation` FROM information_schema.TABLES WHERE TABLES.TABLE_SCHEMA = dbname AND TABLES.TABLE_TYPE = 'VIEW' ) ORDER BY 1; -- Obtaining functions, procedures and triggers ( SELECT ROUTINE_NAME AS `Routine Name`, ROUTINE_TYPE AS `Type`, '' AS `Comment` FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = dbname ORDER BY ROUTINES.ROUTINE_TYPE, ROUTINES.ROUTINE_NAME ) UNION ( SELECT TRIGGER_NAME,'TRIGGER' AS `Type`, concat('On ',EVENT_MANIPULATION,': ',EVENT_OBJECT_TABLE) AS `Comment` FROM information_schema.TRIGGERS WHERE EVENT_OBJECT_SCHEMA = dbname ) ORDER BY 2,1; END$$ DELIMITER ;
|